<?php

/**
 * RedCross Application
 *
 * ProxyConnect class for connecting vanilla forums and the 
 * shift management system.
 *
 * @copyright TODO: Add copyright notice
 */
class Core_ProxyConnectController extends Zend_Controller_Action
{
    public function init()
    {
        $this->_memberService = $this->_helper->getService('Core_Service_Member');
        $this->_authService = RedCross_Factory::getService('Core_Service_Auth');
    }

    public function indexAction()
    {
        //$authInfo = $this->view->authInfo();
        //$auth = Zend_Auth::getInstance();
        //$memberId = (int)$authInfo->getMemberId();
        $user = $this->_authService->getIdentity();

        if (isset($user)) {

        $member = $this->_memberService->fetchByUsername($user->username);
            $memberName = $member->first_name . ' ' . $member->last_name;
            $memberEmail = "";
            foreach ($member->emails as $email) {
                $memberEmail = $email->address;
                if ($email->is_main) {
                    break;
                }
            }

            $this->view->username = $user->username;
            $this->view->memberId = $member->id;
            $this->view->memberName = $memberName;
            $this->view->memberEmail = $memberEmail;
        }

        $this->_helper->layout()->disableLayout();
        $this->getResponse()
             ->setHeader('Content-Type', 'text/plain; charset=utf-8');
    }
}


?>
